﻿// =================================================================== 
// 数据访问层(GDIT.DAL)
//====================================================================
// 文件：DInternalIP.cs
// 项目名称：学院网站
// 创建时间：2012-08-08
// 负责人：ChenZhiGang
//引用DevExpress.Data.Filtering，DevExpress.Xpo程序集
// 程序集介绍：内部IP分段信息数据访问层
// ===================================================================
using GDIT.Model;
using DevExpress.Data.Filtering;
using DevExpress.Xpo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GDIT.Pattern;

namespace GDIT.DAL
{
    public class DInternalIP : IInternalIP
    {

        private XpoHelper.Test<Mtb_InternalIP> userOperation = null;

        /// <summary>
        /// 更新内部IP分段
        /// </summary>
        /// <param name="ip">内部IP</param>
        /// <returns></returns>
        public int UpdateInternalIP(Mtb_InternalIP ip)
        {
            userOperation = new XpoHelper.Test<Mtb_InternalIP>();
            XPCollection xp = userOperation.Operation("OID", 1);
            foreach (Mtb_InternalIP b in xp)
            {
                b.IternalIPStart = ip.IternalIPStart;
                b.IternalIPEnd = ip.IternalIPEnd;
                return XpoHelper.SaveModified(b);
            }
            return 0;
        }

        /// <summary>
        /// 查询并返回内部IP分段
        /// </summary>
        /// <returns></returns>
        public XPCollection SelectInternalIP()
        {
            userOperation = new XpoHelper.Test<Mtb_InternalIP>();
            return userOperation.Operation();
        }

        /// <summary>
        /// 新增内部IP分段
        /// </summary>
        /// <param name="ip">要新增的IP对象</param>
        /// <returns></returns>
        public int AddInternalIP(Mtb_InternalIP ip)
        {
            return XpoHelper.SaveAdded(ip);
        }
    }
}
